import React, {useEffect, useState} from 'react'
import BatchUpload from '@/components/BatchUpload'
import {
	getData,
	getExtendedLease,
	postExtendedLease,
} from '@/service/order/index'

function DelayRent(props: any) {
	const {info, sunchange, getOrderList} = props
	const [batchDelayRent, setBatchDelayRent] = useState(false) // 批量延租
	useEffect(() => {
		setBatchDelayRent(info)
	}, [info])
	const childCange = (value: any) => {
		if (sunchange) {
			sunchange(value)
		}
	}
	const column = [
		{
			title: '订单编号',
			dataIndex: 'orderCarNo',
			align: 'center',
			key: 'orderCarNo',
			width: 200,
		},
		{
			title: '司机名称',
			dataIndex: 'driverName',
			align: 'center',
			key: 'driverName',
			width: 100,
		},
		{
			title: '车牌号',
			dataIndex: 'plateNo',
			align: 'center',
			key: 'plateNo',
			width: 100,
		},
		{
			title: '延租天数',
			dataIndex: 'delayCount',
			align: 'center',
			key: 'delayCount',
			width: 100,
		},
		{
			title: '延租类型',
			dataIndex: 'delayType',
			align: 'center',
			key: 'delayType',
			width: 100,
			render: (text: any) => (
				<>
					{text === 1 && <span>无偿延租</span>}
					{text === 2 && <span>有偿延租</span>}
				</>
			),
		},
		{
			title: '延租日租金',
			dataIndex: 'rentAmount',
			align: 'center',
			key: 'rentAmount',
			width: 100,
		},
		{
			title: '状态',
			dataIndex: 'resultMsg',
			align: 'center',
			key: 'resultMsg',
			width: 200,
			fixed: 'right',
		},
	]
	return (
		<BatchUpload
			isModalOpen={batchDelayRent}
			setIsModalOpen={setBatchDelayRent}
			importData={getExtendedLease} // 导入接口
			onTableList={getData} // 获取列表数据-失败
			getListData={getOrderList} // 获取列表数据-成功
			columns={column}
			sourceId={39}
			templateType="批量申请延租"
			uploadFileUrl={postExtendedLease} // 文件上传接口
			title="申请延租"
			width={800}
			childCange={childCange}
		/>
	)
}

export default DelayRent
